{extend name="base"/}
{block name="resources"}

{/block}
{block name="main"}
<div class="layui-collapse ns-tips">
	<div class="layui-colla-item">
		<h2 class="layui-colla-title">操作提示</h2>
		<ul class="layui-colla-content layui-show">
			<li>站点设置包括网站的基本信息设置</li>

		</ul>
	</div>
</div>

<div class="layui-form ns-form">

	<div class="layui-form-item">
		<label class="layui-form-label">网站开启：</label>
		<div class="layui-input-block">
			<input type="checkbox" name="web_status" value="1" lay-skin="switch" {if condition="$website_info.data.web_status == 1"} checked {/if} />
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">网站域名：</label>
		<div class="layui-input-block">
			<input type="text" name="web_domain" value="{$website_info.data.web_domain}" autocomplete="off" class="layui-input ns-len-long">
		</div>
	</div>


	<div class="layui-form-item">
		<label class="layui-form-label"><span class="required">*</span>网站名称：</label>
		<div class="layui-input-block">
			<input type="text" name="title" lay-verify="required" value="{$website_info.data.title}" autocomplete="off" class="layui-input ns-len-long">
		</div>
<!--		<div class="ns-word-aux">网站名称，将显示在前台顶部欢迎信息等位置</div>-->
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">备案号：</label>
		<div class="layui-input-block">
			<input type="text" name="beian" value="{$website_info.data.beian}" autocomplete="off" class="layui-input ns-len-long">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label img-upload-lable">网站logo：</label>
		<div class="layui-input-block">
			<div class="upload-img-block img-upload">
				<div class="upload-img-box {notempty name="$website_info['data']['logo']"}hover{/notempty}">
					<div class="ns-upload-default" id="webLogoUpload">
						{if condition="$website_info.data.logo"}
						<div id="preview_webLogoUpload" class="preview_img">
							<img layer-src src="{:img($website_info.data.logo)}" class="img_prev"/>
						</div>
						{else/}
						<div class="upload">
							<img src="ADMIN_IMG/upload_img.png"/>
							<p>点击上传</p>
						</div>
						{/if}
					</div>
					<div class="operation">
						<div>
							<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
							<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
						</div>
						
						<div class="replace_img js-replace">点击替换</div>
					</div>
					<input type="hidden" name="logo" value="{$website_info.data.logo}">
				</div>
			</div>
		</div>
		<div class="ns-word-aux">默认网站LOGO，通用头部显示，最佳显示尺寸为200px*60px</div>
	</div>

	<div class="layui-form-item" hidden>
		<label class="layui-form-label">网站描述：</label>
		<div class="layui-input-block">
			<textarea name="desc" class="layui-textarea ns-len-long">{$website_info.data.desc}</textarea>
		</div>
	</div>

	<div class="layui-form-item" hidden>
		<label class="layui-form-label">网站关键字：</label>
		<div class="layui-input-block">
			<input type="text" name="keywords" value="{$website_info.data.keywords}" autocomplete="off" class="layui-input ns-len-long">
		</div>
		<div class="ns-word-aux">用于网站搜索引擎的优化，关键字之间请用英文逗号分隔</div>
	</div>

	<div class="layui-form-item" hidden>
		<label class="layui-form-label">网站地址：</label>
		<div class="layui-input-block">
			<input type="text" name="web_address" value="{$website_info.data.web_address}" autocomplete="off" class="layui-input ns-len-long">
		</div>
	</div>

	<div class="layui-form-item" hidden>
		<label class="layui-form-label img-upload-lable">网站公众号二维码：</label>
		<div class="layui-input-block">
			<div class="upload-img-block img-upload">
				<div class="upload-img-box {notempty name="$website_info.data.web_qrcode"}hover{/notempty}">
					<div class="ns-upload-default" id="webQrcodeUpload">
						{if condition="$website_info.data.web_qrcode"}
						<div id="preview_webQrcodeUpload" class="preview_img">
							<img layer-src src="{:img($website_info.data.web_qrcode)}" class="img_prev"/>
						</div>
						{else/}
						<div class="upload">
							<img src="ADMIN_IMG/upload_img.png"/>
							<p>点击上传</p>
						</div>
						{/if}
					</div>
					<div class="operation">
						<div>
							<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
							<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
						</div>
						
						<div class="replace_img js-replace">点击替换</div>
					</div>
					<input type="hidden" name="web_qrcode" value="{$website_info.data.web_qrcode}">
				</div>
			</div>
		</div>
	</div>

	<div class="layui-form-item" hidden>
		<label class="layui-form-label">网站邮箱：</label>
		<div class="layui-input-block">
			<input type="text" name="web_email" value="{$website_info.data.web_email}" autocomplete="off" class="layui-input ns-len-long">
		</div>
	</div>
	
	<div class="layui-form-item">
		<label class="layui-form-label">平台客服电话：</label>
		<div class="layui-input-block">
			<input type="text" name="web_phone" value="{$website_info.data.web_phone}" autocomplete="off" class="layui-input ns-len-long">
		</div>
	</div>
	
	<div class="layui-form-item" hidden>
		<label class="layui-form-label">网站QQ：</label>
		<div class="layui-input-block">
			<input type="text" name="web_qq" value="{$website_info.data.web_qq}" autocomplete="off" class="layui-input ns-len-long">
		</div>
	</div>
	
	<div class="layui-form-item" hidden>
		<label class="layui-form-label">网站微信：</label>
		<div class="layui-input-block">
			<input type="text" name="web_weixin" value="{$website_info.data.web_weixin}" autocomplete="off" class="layui-input ns-len-long">
		</div>
	</div>
	
	<!--<div class="layui-form-item">-->
		<!--<label class="layui-form-label">手机端域名：</label>-->
		<!--<div class="layui-input-block">-->
			<!--<input type="text" name="wap_domain" value="{$website_info.data.wap_domain}" autocomplete="off" class="layui-input ns-len-long">-->
		<!--</div>-->
	<!--</div>-->



	{if addon_is_exit('pc')}
	<!--<div class="layui-form-item" hidden>
		<label class="layui-form-label">pc端是否启用：</label>
		<div class="layui-input-block">
			<input type="checkbox" name="web_status" value="1" lay-skin="switch" {if condition="$website_info.data.web_status == 1"} checked {/if} />
		</div>
	</div>-->
	{/if}
	<div class="layui-form-item" hidden>
		<label class="layui-form-label">手机端是否启用：</label>
		<div class="layui-input-block">
			<input type="checkbox" name="wap_status" value="1" lay-skin="switch" {if condition="$website_info.data.wap_status == 1"} checked {/if} />
		</div>
	</div>

	<div class="layui-form-item" hidden>
		<label class="layui-form-label">网站关闭原因：</label>
		<div class="layui-input-block">
			<textarea name="close_reason" class="layui-textarea ns-len-long">{$website_info.data.close_reason}</textarea>
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">关于我们：</label>
		<div class="layui-input-inline">
			<script id="editor" type="text/plain" class="ns-special-length" style="height:300px;"></script>
		</div>
	</div>
<input type="hidden" name="" id="agreementContent" value="{$website_info.data.aboutus}" />

	<div class="ns-form-row">
		<button class="layui-btn ns-bg-color" lay-submit lay-filter="save">保存</button>
	</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" charset="utf-8" src="STATIC_EXT/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="STATIC_EXT/ueditor/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="STATIC_EXT/ueditor/lang/zh-cn/zh-cn.js"></script>
<script>
	var ue = UE.getEditor('editor');

	if($("#agreementContent").val()){
		ue.ready(function() {
			ue.setContent($("#agreementContent").val());
		});
	}

	layui.use(['form'], function() {
		var form = layui.form,
			repeat_flag = false; //防重复标识
		form.render();
		form.on('submit(save)', function(data) {
			if (data.field.web_status == undefined) {
				data.field.web_status = 0;
			}

			if (data.field.wap_status == undefined) {
				data.field.wap_status = 0;
			}
			data.field.aboutus = ue.getContent();
			if (repeat_flag) return;
			repeat_flag = true;
			
			//图片删除
			if(!data.field.logo) web_upload.delete();
			if(!data.field.web_qrcode) web_qrcode_upload.delete();
			
			$.ajax({
				type: 'POST',
				dataType: 'JSON',
				url: ns.url("admin/config/webConfig"),
				data: data.field,
				success: function(res) {
					layer.msg(res.message);
					if (res.code == 0) {
						location.reload();
					}else{
						repeat_flag = false;
					}
				}
			});
		});

		// 上传logo
		var web_upload = new Upload({
			elem: '#webLogoUpload',
			url: ns.url("admin/upload/upload"),
		});

		// 二维码
		var web_qrcode_upload = new Upload({
			elem: '#webQrcodeUpload',
			url: ns.url("admin/upload/upload"),
		});

	});
</script>
{/block}